/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |				
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  8                                   	
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application     pimpleFoam;

//startFrom       startTime;
startFrom       latestTime;

startTime       0;

stopAt          endTime;

endTime         500;

deltaT          0.001;

writeControl    runTime;

writeInterval   1;

purgeWrite      0;

writeFormat     ascii;

writePrecision  8;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable yes;

adjustTimeStep  yes;

maxCo           0.9;
maxDeltaT       0.1;

// ************************************************************************* //

functions
{

///////////////////////////////////////////////////////////////////////////
    inMassFlow
    {
        type            surfaceFieldValue;
        functionObjectLibs ("libfieldFunctionObjects.so");
        enabled         false;

//        writeControl     outputTime;
	writeControl   timeStep;
	writeInterval  1;

        log             true;

        writeFields     false;

        regionType          patch;
        name      in;

	operation       sum;
        fields
        (
            phi
        );
    }
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
    outMassFlow
    {
        type            surfaceFieldValue;
        functionObjectLibs ("libfieldFunctionObjects.so");
        enabled         false;

//      writeControl     outputTime;

	writeControl   timeStep;
	writeInterval  1;

        log             yes;

        writeFields     false;

        //writeFields     true;
        //surfaceFormat   raw;

        regionType          patch;
        name      out;

	operation       sum;
        fields
        (
            phi
        );
    }
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////

    additional_fields
    {
        type writeRegisteredObject;
        functionObjectLibs ( "libIOFunctionObjects.so" );

	//Remember, when in doubt, use bananas        
	//objectNames ("bananas");
	  objectNames ("U_0");
	//objectNames ("y");

        enabled         false;

        timeStart       100;
        timeEnd         200;

        writeControl     outputTime;

/*
	writeControl   timeStep;
	writeInterval  1;
*/
    }

///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////

    fieldAverage
    {
        type            fieldAverage;
        functionObjectLibs ("libfieldFunctionObjects.so");
        enabled         true;
        writeControl   outputTime;

//writeControl   timeStep;
//writeInterval  100;

//cleanRestart true;

/*
        timeStart       20;
        timeEnd         200;
*/

        fields
        (
            U
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }

            p
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }
        );
    }

///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////

forces_object
{
	type forces;
	functionObjectLibs ("libforces.so");

        enabled         false;

	//writeControl outputTime;
	writeControl   timeStep;
	writeInterval  1;

	//// Patches to sample
	//patches ("body1" "body2" "body3");
	patches ("cylinder");

	//// Name of fields
	pName p;
	Uname U;

	//// Density
	rho rhoInf;
	rhoInf 1.225;

	//// Centre of rotation
	CofR (0 0 0);
}

///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////

forceCoeffs_object
{
	// rhoInf - reference density
	// CofR - Centre of rotation
	// dragDir - Direction of drag coefficient
	// liftDir - Direction of lift coefficient
	// pitchAxis - Pitching moment axis
	// magUinf - free stream velocity magnitude
	// lRef - reference length
	// Aref - reference area
	type forceCoeffs;
	functionObjectLibs ("libforces.so");
	//patches ("body1" "body2" "body3");
	patches ("cylinder");

	pName p;
	Uname U;
	rho rhoInf;
	rhoInf 1.0;

	//// Dump to file
	log true;

	CofR (0.0 0 0);
	liftDir (0 1 0);
	dragDir (1 0 0);
	pitchAxis (0 0 1);
	magUInf 1.0;
	lRef 1.0;         // reference lenght
	Aref 2.0;         // reference area 1 for 2d

        writeControl   timeStep;
        writeInterval  1;
}

///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////

minmaxdomain
{
	type fieldMinMax;
	//type banana;

	functionObjectLibs ("libfieldFunctionObjects.so");

	enabled true;

	mode component;

	writeControl timeStep;
	writeInterval 1;

	log true;

	fields (p U k omega);
      //fields (p U y);
}

///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////

yplus
{
    type                yPlus;
    functionObjectLibs  ("libutilityFunctionObjects.so");

    enabled true;

    writeControl outputTime;
    //writeControl timeStep;
    //writeInterval 1;

    //log true;
}

///////////////////////////////////////////////////////////////////////////

};
